import { defineStore } from 'pinia';

export const useNotificationStore = defineStore('notification', {
    state: () => ({
        text: '',
        color: 'success',
        timeout: 3000,
        show: false,
    }),
    actions: {
        showNotification({ text, color = 'success', timeout = 3000 }) {
            this.text = text;
            this.color = color;
            this.timeout = timeout;
            this.show = true;
        },
        success(text) {
            this.showNotification({ text, color: 'success' });
        },
        error(text) {
            this.showNotification({ text, color: 'error' });
        },
        warning(text) {
            this.showNotification({ text, color: 'warning' });
        },
        info(text) {
            this.showNotification({ text, color: 'info' });
        }
    },
});